#!/usr/bin/env python
from google.appengine.ext import db
    
# New Professor Modules # Containing Course Data

class Lecturer(db.Model):
    user=db.UserProperty(auto_current_user_add=True); # For google user
    name=db.StringProperty()
    # courses=db.ListProperty(db.ReferenceProperty(), default=[])
    
class Course(db.Model):
    lecturer = db.ReferenceProperty(Lecturer)
    name=db.StringProperty()
    # lectures=db.ListProperty(db.ReferenceProperty(), default=[])
    
class Lecture(db.Model):
    course = db.ReferenceProperty(Course)
    index = db.IntegerProperty()
    name = db.StringProperty()
    # topics = db.ListProperty(db.ReferenceProperty(), default=[])
    # questions = db.ListProperty(db.ReferenceProperty(), default=[])
    
class Topic(db.Model):
    lecture = db.ReferenceProperty(Lecture)
    index = db.IntegerProperty()
    name = db.StringProperty()
    time = db.IntegerProperty()
    
class Question(db.Model):
    # lecturerID = db.ReferenceProperty(Lecturer)
    # lectureID = db.ReferenceProperty(Lecture)
    lecture = db.ReferenceProperty(Lecture)
    name = db.StringProperty()
    text = db.StringProperty()
    answers = db.ListProperty(str, default=[])
    #correctAnswer = db.IntegerProperty()

class QuestionAnswer(db.Model):
    question = db.ReferenceProperty(Question)
    answer = db.StringProperty()
    userID = db.IntegerProperty()

# Parent is Lecture
class ClassState(db.Model):
    lecture = db.ReferenceProperty(Lecture)
    currentTopic = db.ReferenceProperty(Topic)
    currentTopicTime = db.TimeProperty()
    # Quiz Related
    isQuizOn = db.BooleanProperty()
    quizQuestion = db.ReferenceProperty(Question)
    ended = db.BooleanProperty()

class StudentVoice(db.Model):
    topic = db.ReferenceProperty(Topic)
    understand = db.BooleanProperty()
    when = db.TimeProperty(auto_now_add=True)
    userID = db.IntegerProperty()